#ifndef ParallelMPIFACTORY_H
#define ParallelMPIFACTORY_H

#include "../Parallel/ParallelMPI.h"
#include "../Parallel/ParallelMPI1D.h"
#include "../Parallel/ParallelMPI2D.h"
#include "../Parallel/ParallelMPI3D.h"

#include "../Input/PicParams.h"

#include "../Tool/Macros.h"

// --------------------------------------------------------------------------------------------------------------------
//Class ParallelMPIFactory
// --------------------------------------------------------------------------------------------------------------------
class ParallelMPIFactory {
public:
    // --------------------------------------------------------------------------------------------------------------------
    //Create appropriate MPI environment for the geometry
    //\param params : Parameters
    //\param pmpiData : Initial MPI environment (data broadcast)
    // --------------------------------------------------------------------------------------------------------------------
    static ParallelMPI* create(PicParams* params_, ParallelMPI* pmpi_)
    {
        ParallelMPI* pmpi = NULL;
        if ( params_->geometry == "1d3v" )
        {
            pmpi = new  ParallelMPI1D(params_, pmpi_);
        }
        else if ( params_->geometry == "2d3v" )
        {
            pmpi = new  ParallelMPI2D(params_, pmpi_);
        }
        else if ( params_->geometry == "3d3v" )
        {
            pmpi = new  ParallelMPI3D(params_, pmpi_);
        }
        else 
        {
            log_error<<"Geometry " << params_->geometry << " not implemented";
        }

        return pmpi;
    }

};

#endif
